Source code and object code refer to the “before” and “after” versions of a computer program that is compiled before it is ready to run in a computer. The source code consists of the programming statements that are created by a programmer with a text editor or a visual programming tool and then saved in a file. For example, a programmer using the C language types in a desired sequence of C language statements using a text editor and then saves them as a named file. This file is said to contain the source code. It is now ready to be compiled with a C compiler and the resulting output, the compiled file, is often referred to as object code. The object code file contains a sequence of instructions that the processor can understand but that is difficult for a human to read or modify. Many compilers include an option to generate optimized object code instructions in an effort to increase the efficiency associated with the execution of computer programs.
Optimizing a computer program generally serves to eliminate portions of computer code which are unused or unnecessary. Optimizing a computer program may restructure computational operations to be performed more efficiently, thereby consuming fewer computer resources. An optimizer is arranged to effectively transform a computer program, e.g., a computer program written in a programming language into a faster program. The faster, or optimized, program continues to preserve correctness while generally performing substantially all the same functions as the original, pre-converted computer program using fewer computations.
Debugging programs, also referred to as debuggers, allow developers to find errors in software programs by halting execution of the program at specified points. For example, the developer can set break points to halt execution of the program when a particular line in the source code is executed, when a particular variable is modified, or when a specified condition is met. While the program is halted, the developer can specify variable names to view their corresponding values. Developers can also view lines of the source code from which the executable computer program was compiled. Some debuggers also allow the programmer to fix the error and/or restart the program; trace the flow of processing through an executing program; execute the program statement by statement; redirect the flow of the program execution; send the processing to a specific place in the program; display the source program; specify conditions under which the program execution is to pass to the debugger; redirect the program output to the printer or back to the terminal screen; display the stack of subroutine return addresses, and/or remove addresses from the top of the stack.
Compilers encode debugging information in the object code, which debuggers use to map source lines with the generated machine instructions that get executed, and source variables with memory and data locations that hold the values of these variables, along with other information. Most compilers, however, only provide debugging information for unoptimized programs; not for optimized programs. As a result, address locations of variables and instructions in the address maps for the unoptimized code used by the debugger may not be aligned with the true locations in the optimized code. Optimizers that do provide information to debuggers typically do not assure that the information is accurate.